package erfgame.core.world.terrain.color;


import erfgame.core.Rotation;
import erfgame.core.world.World;
import erfgame.core.world.terrain.GridSettings;
import erfgame.core.world.terrain.rotated.TransformedBlock;

public class GridTerrainColorMapFactoryProxy 
	implements TerrainColorMapFactory {
	
	private TerrainColorMapFactory proxied;
	private GridSettings gridSettings;
	private int gridColor;
	
	public GridTerrainColorMapFactoryProxy( 
			TerrainColorMapFactory proxied, 
			int gridColor,
			GridSettings gridSettings
	) {
		this.proxied = proxied;
		this.gridColor = gridColor;
		this.gridSettings = gridSettings;
	}

	public int[][][] getColorMap(World world, int width, int height, int depth) {
		int[][][] result;
		result = proxied.getColorMap(world, width, height, depth);
		TransformedBlock<int[]> colors = new TransformedBlock<int[]>(
				result,
				Rotation.degrees0, 
				Rotation.degrees0.getRotateInBoxTransformation(width-1, height-1),
				width, 
				height
		);
		GridTerrainColorSourceProxy.overlayGrid( 
				colors,
				depth, 
				gridColor, 
				world.getGridDiagonalMask(), 
				gridSettings
		);
		return result;
	}

}
